Passing callback as parameter to another function JavaScript

Hi there,

below library gives you in detail of how we can optimise the code in javascript

upload this library either formload or in html webresource

//start
function testhtml()
{
mactest.htmlOnload();
}

mactest= {
//Ends
findlinkurl: function (findurlparm) {

alert(“just entered findlinkurl” + findurlparm);

},

htmlOnload: function () {
alert(“welcome to hello world”);
mactest.getserviceurl(“test1param”, mactest.findlinkurl)
},

getserviceurl: function (test1, callbackname) {
alert(“Inside the test1 and test2 values” + test1);
test1 = “findurlparam1”;
callbackname(test1);
}
};

call testhtml() function from any event trigger
output:

welcome to hello world
Inside the test1 and test2 valuestest1param
just entered findlinkurlfindurlparam1

Thanks,

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.